package com.makefuture.GeneratorModel;

import javax.sql.DataSource;

import com.jfinal.kit.PathKit;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.generator.Generator;
import com.jfinal.plugin.c3p0.C3p0Plugin;

public class TestGenerator {

	
	public static DataSource getDataSource() {
		PropKit.use("a_little_config.txt");
		 C3p0Plugin c3p0Plugin = new C3p0Plugin(PropKit.get("jdbcUrl").trim(), PropKit.get("user").trim(), PropKit.get("password").trim(),PropKit.get("jdbcDriver").trim());
         c3p0Plugin.start();
		 return c3p0Plugin.getDataSource();
		
	}
	
	/**
	 * 四个参数分别表示baseMode的包名，baseModel的输出路径，modle的包名，model的输出路径。 
	 * @param args
	 */
	public static void main(String[] args) {
		
		String baseModelPaceName = "com.du.model.base";//base model 包名
		String baseModelOutputDir = PathKit.getRootClassPath()+"/../../../src/com/du/model/base";//base mode 输出目录
		String modelPackName = "com.du.model";
		String modelOutputDir = baseModelOutputDir + "/..";
		
		Generator generator = new Generator(getDataSource(), baseModelPaceName,
				baseModelOutputDir,modelPackName,modelOutputDir);
		
		//generator.addExcludedTable("");//添加不需要生成的表名
		generator.setGenerateDaoInModel(true);//是否生成Dao层
		generator.setGenerateDataDictionary(true);//是否生成字典文件


		generator.generate();
	}
	
}
